<include file="./Application/Common/View/pageheader.html" />

<div class="row">
<div class="col-sm-12">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>修改医生信息</h5>
            <ol class="breadcrumb pull-right">
                <li>
                    <a href="{:U('Admin/Doctors/index')}"><strong>返回上一页</strong></a>
                </li>
            </ol>
        </div>
        <div class="ibox-content">		
			<form class="form-horizontal col-sm-12" action="{:U('Admin/Doctors/editDoctors')}" method="POST">
				<input type="hidden" name="id" value="{$Doctors.id}">
				<div class="form-group">
					<label class="col-sm-3 control-label">医生电话</label>
					<div class="col-sm-7">
						<input name="phone" class='form-control' placeholder="医生电话" value="{$Doctors.phone}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">医院</label>
					<div class="col-sm-7">
						<select class="form-control" name="hospital_id" id="hospital" onchange="javascript:getKeshi();">
							<foreach name="Hospital" item="vo">
							<option value="{$vo['id']}" <if condition="$vo['id'] eq $Doctors.hospital_id">selected</if> >{$vo['name']}</option>
							</foreach> 
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">科室</label>
					<div class="col-sm-7">
						<select class="form-control" name="keshi_id" id="keshi">
							<foreach name="Keshi" item="vo">
							<option value="{$vo['id']}" <if condition="$vo['id'] eq $Doctors.keshi_id">selected</if> >{$vo['name']}</option>
							</foreach> 
						</select>
					</div>
				</div>
				
				<div class="clearfix"></div>
				<div class="from-group">
					<button class='btn btn-success'>确认</button>
				</div>
            </form>
            <div class="clearfix"></div>
		</div>
    </div>
</div>

<include file="./Application/Common/View/pagefooter.html" />
<script>
	function getKeshi() {
		var hospital_id = $("#hospital option:selected").val();
		$.get("/Admin/Doctors/ajaxKeshi", { hospital_id: hospital_id },
			function(data){
				if(data == null) {
					$("#keshi").html('null');
					return true;
				}
				return rendKeshi(data);
			}
		);
	}
	
	function rendKeshi(data) {
		//console.log(data);
		var optionHtml = '';
		var html='';
		var count = data.length;
		var i;
		for(i=0; i<count; i++)
		{
			optionHtml = '<option value="'+data[i].keshi_id+'">'+data[i].name+'</option>'; 
			html = html + optionHtml;
		}
		$("#keshi").html(html);
		
	}
</script>